<?php

class ConcreteIterator extends IIterator
{
    private $aggregate;
    private $current_index;

    public function __construct($aggregate)
    {
        $this->aggregate = $aggregate;
        $this->current_index = 0;
    }

    public function first()
    {
        return $this->aggregate->getItem(0);
    }

    public function next()
    {
        $this->current_index++;
        return $this->currentItem();
    }

    public function isDone()
    {
        return $this->current_index >= $this->aggregate->getCount();
    }

    public function currentItem()
    {
        if ($this->current_index < $this->aggregate->getCount()) {
            return $this->aggregate->getItem($this->current_index);
        }
        return null;
    }
}